package com.xz.stu.server.controller;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import com.xz.stu.server.vo.calenderEvent.*;
import com.xz.stu.server.service.CalendarEventService;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;


import java.util.List;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

@Tag(name = "管理后台 - 校历事件")
@RestController
@RequestMapping("admin-api/school/calendar/event")
@Validated
public class CalendarController {

    @Resource
    private CalendarEventService calendarEventService;

    @PostMapping("/create")
    @Operation(summary = "创建事件")
    public CommonResult<Long> createEvent(@Valid @RequestBody CalendarEventCreateReqVO createReqVO) {
        return success(calendarEventService.createEvent(createReqVO));
    }

    @PutMapping("/update")
    @Operation(summary = "更新事件")
    public CommonResult<Boolean> updateEvent(@Valid @RequestBody CalendarEventUpdateReqVO updateReqVO) {
        calendarEventService.updateEvent(updateReqVO);
        return success(true);
    }

    @DeleteMapping("/delete/{id}")
    @Operation(summary = "删除事件")
    public CommonResult<Boolean> deleteEvent(@PathVariable("id")List<Long>  id) {
        calendarEventService.deleteEvent(id);
        return success(true);
    }

    @GetMapping("/get/{id}")
    @Operation(summary = "获得事件")
    public CommonResult<CalendarEventRespVO> getEvent(@PathVariable("id") Long id) {
        return success(calendarEventService.getEvent(id));
    }

    @GetMapping("/list")
    @Operation(summary = "获得事件列表")
    public CommonResult<List<CalendarEventRespVO>> getEventList(@Valid CalendarEventListReqVO listReqVO) {
        return success(calendarEventService.getEventList(listReqVO));
    }
    @GetMapping("/listPage")
    @Operation(summary = "获得事件列表-分页")
    public CommonResult<PageResult<CalendarEventRespVO>> getEventListPage(@Valid CalendarEventListPageReqVO listReqVO) {
        return success(calendarEventService.getEventLisPage(listReqVO));
    }
}
